package data;

import java.io.Serializable;
import user.Customer;
import java.util.Date;
import java.util.Vector;

/*
 * @author Γκαμπέρλο Ναϊμ
 * @author Μώτος Διονύσης
 * @author Παπαδημητρίου Δημήτρης
 * @author Παπαδόπουλος Αλέξανδρος p3080138
 * @author Παπαδόπουλος Λεωνίδας p3080139
 */

public class Order implements Serializable{

    private static int IDDistributor=0;
    private int ID;
    private Offer offer;
    private Date time;
    private Vector<Product> products;
    private Customer customer;
    private boolean delivered;

/**
     * Order Order(Customer customer, Offer offer)
     * 
     * "Dimiourgia antikeimenou typoy Order,me parametrous to customer kai to offer.O kataskeuastis
     * arxikopoiei tin paraggelia."
     * @param customer
     * @param offer
     */

    public Order(Customer customer, Offer offer ) {
        ID = IDDistributor++;
        this.customer = customer;
        this.offer = offer;
        this.time = new Date(); 
        this.products = new Vector<Product>();
    }
    
/**
     * Order getCustomer()
     * 
     * "Epistrefi ton pelati tis paraggelias ws ena antikeimeno typou Customer."
     * @return Order's customer	
     */
    public Customer getCustomer() {
        return customer;
    }


/**
     * Order setCustomer(Customer customer)
     * 
     * "Orismos tou pelati tis trexousas paraggelias ."
     * @param customer
     * 
     */
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

/**
     * Order isDelivered()
     * 
     * "Epistrefi mia timi boolean(true-false) ,i opoia perigrafi an i paraggelia exei paradothei i oxi"
     * @return True if order is delivered-False if not.
     */
    public boolean isDelivered() {
        return delivered;
    }

/**
     * Order setDelivered(boolean delivered)
     * 
     * "Orizei an i paraggelia exei ektelesti i oxi."
     * @param delivered
     * 
     */

    public void setDelivered(boolean delivered) {
        this.delivered = delivered;
    }

/**
     * Order getTime()
     * 
     * "Epistrefei tin wra pou pragmatopoiithike i paraggelia.O tipos tou antikeimenou pou epistrefei einai tipou String"
     * @return Wra tis pragmatopoiisis paraggelias
     */
    public String getTime() {
        return time.toString();
    }

/**
     * Order getOffer()
     * 
     * "Epistrefei tin prosfora pou einai monadiki gia kathe paraggelia.O tipos tou antikeimenou pou epistrefei einai Offer"
     * @return Offer Prosfora tis paraggelias
     */

    public Offer getOffer() {
        return offer;
    }

/**
     * Order getTotalCost()
     * 
     * "Ypologismos tou sinolikou kostous tis paraggelias.O tipos tou antikeimenou pou epistrefei einai tipou Float"
     * @return Float Sinoliko kostos paraggelias
     */

    public float getTotalCost() {
        float totalCost=0;
        for ( Product p : products )
            totalCost += p.getCost();
        return totalCost;
    }

/**
     * Order getID()
     * 
     * "Epistrefei to monadiko ID tipou Integer pou exei i kathe paraggelia"
     * @return int To monadiko ID tis paraggelias
     */

    public int getID() {
        return ID;
    }

/**
     * Order getProducts()
     * 
     * "Epistrefei to sinolo twn proiontwn tis paraggelias. O tipos tou antikeimenou pou epistrefei i sinartisi einai tipou Vector<Product>"
     * @return Vector<Product> To sinolo twn proiontwn tis paraggelias
     */

    public Vector<Product> getProducts() {
        return products;
    }

/**
     * Order addProduct(Product prod)
     * 
     * "Prosthetei stin paraggelia ena proion tipou product. To antikeimeno prostithetai sti lista twn products"
     * @param prod
     */
    public void addProduct(Product prod) {
        products.addElement(prod);
    }

/**
     * Order removeProduct(int i)
     * 
     * "Diagrafi ena antikeimeno apo ti lista twn proiontwn tou antikeimenou Order. Gia tin diagrafi apaiteitai o antistoixos deiktis
     *  tou proiontos "
     * @param i
     *
     */
    
    public void removerProduct(int i){
        products.remove(i);
    }
}
